<%-- Created by IntelliJ IDEA. User: chenjun Date: 2022/2/24 Time: 10:00 To change this template use File | Settings |
    File Templates. --%>
    <% String path=request.getContextPath(); String basePath=request.getScheme() + "://" + request.getServerName() + ":"
        + request.getServerPort() + path + "/" ; %>
        <%@ page contentType="text/html;charset=UTF-8" language="java" %>
            <!DOCTYPE html>
            <html>

            <head>
                <base href="<%=basePath%>">
                <title>需求计划</title>
                <meta http-equiv="pragma" content="no-cache">
                <meta http-equiv="cache-control" content="no-cache">
                <meta http-equiv="expires" content="0">
                <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
                <meta http-equiv="description" content="This is my page">
            </head>
            <style>
                .tdText {
                    text-align: right;
                    width: 400px;
                    height: 20px;
                }

                input:disabled {
                    background-color: #dae1ed;
                }
            </style>

            <body>
                <%@ include file="/WEB-INF/jsp/common/header.jsp" %>
                    <%@ include file="/WEB-INF/jsp/common/loadDiv.jsp" %>

                        <script type="text/javascript">
                            $(function () {
                                $('#startTime').datebox('setValue', getBeforeCurrentDate90Days());
                                $('#endTime').datebox('setValue', getNowFormatDate());
                                bingGrid();
                                // selectInquiryList();
                            });
                        </script>

                        <div style="margin: 5px 0px">
                            <%-- 搜索框 --%>
                                <label style="font-size: 12px;">创建时间：</label> <input class="easyui-datebox"
                                    name="startTime" id="startTime"
                                    data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
                                    value="" style="width: 150px"> <label style="font-size: 10px;">~</label> <input
                                    class="easyui-datebox" name="endTime" id="endTime"
                                    data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
                                    style="width: 150px" /> <a id="search" href="javascript:void(0)"
                                    class="easyui-linkbutton" data-options="iconCls:'icon-search'"
                                    onclick="selectList()">查询</a> <a id="export" href="javascript:void(0)"
                                    class="easyui-linkbutton" data-options="iconCls:'icon-export'"
                                    onclick="exportList()">导出</a>
                        </div>
                        <%--需求计划列表DataGrid --%>
                            <table id="demand"></table>
                            <%-- 详情弹窗 --%>
                                <div id="needDetailWindow" class="easyui-window" closed="true" modal="true"
                                    title="需求计划详情" style="width: 900px; height: 400px; padding: 5px 5px">
                                    <div id="needMmBaseInfo" class="easyui-tabs" style="width: 875px; height: 350px">
                                        <div title="基本信息" style="padding: 5px;">
                                            <table>
                                                <tr style="margin-bottom: 10px">
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">计划编码：</label> <input
                                                            id="nedCode" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">计划名称：</label> <input
                                                            id="nedName" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">计划类别：</label> <input
                                                            id="nedCategory" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                </tr>
                                                <tr style="margin-bottom: 10px">
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">计划类型：</label> <input
                                                            id="nedType" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">物资类型：</label> <input
                                                            id="nedMmType" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">项目编码：</label> <input
                                                            id="nedProCode" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                </tr>
                                                <tr style="margin-bottom: 10px">
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">项目名称：</label> <input
                                                            id="nedProName" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">采购类型：</label> <input
                                                            id="nedPurType" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">成本中心编码：</label>
                                                        <input id="nedCostCode" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%">
                                                    </td>
                                                </tr>
                                                <tr style="margin-bottom: 10px">
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">成本中心名称：</label>
                                                        <input id="nedCostName" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%">
                                                    </td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">使用单位编码：</label>
                                                        <input id="nedDeptCode" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%">
                                                    </td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">使用单位名称：</label>
                                                        <input id="nedDeptName" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%">
                                                    </td>
                                                </tr>
                                                <tr style="margin-bottom: 10px">
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">领料单位编码：</label>
                                                        <input id="nedGetDeptCode" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%">
                                                    </td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">领料单位名称：</label>
                                                        <input id="nedGetDeptName" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%">
                                                    </td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">是否急用：</label> <input
                                                            id="nedIsUrgent" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                </tr>
                                                <tr style="margin-bottom: 10px">
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">流程类型：</label> <input
                                                            id="nedFlowType" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>

                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">创建时间：</label> <input
                                                            id="createTime" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">创建人：</label> <input
                                                            id="createName" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                </tr>
                                                <tr style="margin-bottom: 10px">
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">更新人：</label> <input
                                                            id="updateName" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">更新时间：</label> <input
                                                            id="updateTime" class="easyui-validatebox textbox"
                                                            data-options="readonly:true" style="width: 60%"></td>
                                                </tr>
                                                <tr>
                                                    <td colspan="1" class="tdText"><label
                                                            style="width: 40%; text-align: right;">相关说明：</label> <input
                                                            id="nedExplain" class="easyui-validatebox textbox"
                                                            data-options="readonly:true,multiline:true"
                                                            style="width: 60%; height: 100px"></td>
                                                </tr>
                                            </table>
                                        </div>
                                        <div title="物资明细" style="overflow: auto; padding: 5px;">
                                            <table id="needMmDetailList"></table>
                                        </div>
                                    </div>

                                </div>
            </body>
            <script type="text/javascript">
                // 需求计划详情窗口赋值
                function setNeedPlanDetailWindowValue(index) {
                    const rows = $('#demand').datagrid('getRows');
                    let item = rows[index];
                    $('#nedCode').val(item.nedCode);
                    $('#nedName').val(item.nedName);
                    $('#nedCategory').val(item.nedCategory);
                    $('#nedMmType').val(item.nedMmType);
                    $('#nedType').val(item.nedType);
                    $('#nedProCode').val(item.nedProCode);
                    $('#nedProName').val(item.nedProName);
                    $('#nedPurType').val(item.nedPurType);
                    $('#nedCostCode').val(item.nedCostCode);
                    $('#nedCostName').val(item.nedCostName);
                    $('#nedDeptCode').val(item.nedDeptCode);
                    $('#nedDeptName').val(item.nedDeptName);
                    $('#nedGetDeptCode').val(item.nedGetDeptCode);
                    $('#nedIsUrgent').val(item.nedIsUrgent);
                    $('#nedFlowType').val(item.nedFlowType);
                    $('#createTime').val(item.createTime);
                    $('#createName').val(item.createName);
                    $('#updateName').val(item.createName);
                    $('#updateTime').val(item.createName);
                    $('#nedExplain').val(item.nedExplain);
                    if (!item.nedId) return
                    // 构建物资明细的dataGrid
                    let needMmDetailList = $('#needMmDetailList')
                    needMmDetailList.datagrid({
                        title: '',
                        // data: gridData,
                        queryParams: {
                            nedId: item.nedId
                        },
                        fitColumns: true,
                        url: 'purchase/need/selectNeedMmList',
                        iconCls: 'icon-application',
                        clientPaging: false,
                        remoteFilter: true,
                        filterDelay: 0,
                        width: 860,
                        height: 300,
                        nowrap: true,
                        rownumbers: true,
                        animate: false,
                        collapsible: false,
                        singleSelect: true,
                        pageSize: 8,
                        pageList: [8, 18, 28, 50],
                        remoteSort: true,
                        pagination: true,
                        frozenColumns: [[{
                            field: 'mmId',
                            title: '物资id',
                            hidden: true,
                            sortable: true,
                            width: 100,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedMmCode',
                            title: '物资编码',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        }]],
                        columns: [[{
                            field: 'nedMmDetail',
                            title: '物资描述',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        }, {
                            field: 'nedMmUnit',
                            title: '计量单位',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'mmUnitDetail',
                            title: '计量单位描述',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedMmCategory',
                            title: '物资品名',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedMmMain',
                            title: '主特征',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedMmSecond',
                            title: '副特征',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedMmNature',
                            title: '计量性质',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedMmTypeCode',
                            title: '物资类别编码',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedMmTypeName',
                            title: '物资类别名称',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedPlanNum',
                            title: '需求计划量',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedStockNum',
                            title: '库存量',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedNeedDate',
                            title: '需用日期',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedDevice',
                            title: '设备位号',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedQm',
                            title: '质量技术要求',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedUse',
                            title: '用途',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedUseName',
                            title: '使用人姓名',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedUseTel',
                            title: '使用人联系方式',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedOutType',
                            title: '出库类型',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedRemark',
                            title: '备注',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'createTime',
                            title: '创建时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'createName',
                            title: '创建人',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        }
                        ]],
                        toolbar: [],
                        onLoadSuccess: function () {

                        },
                        onDblClickRow: function () {

                        }
                    });
                    // needMmDetailList.datagrid('enableFilter');
                    $('#needDetailWindow').window('open');
                }

                // 导出需求计划列表
                function exportList() {
                    var startTime = $('#startTime').datebox('getValue') ? $('#startTime').datebox('getValue') : '';
                    var endTime = $('#endTime').datebox('getValue') ? $('#endTime').datebox('getValue') : '';
                    window.open("purchase/need/exportNeed?startTime=" + startTime + "&endTime=" + endTime);
                }

                // 按时间查询需求计划列表
                function selectList() {
                    var startTime = $('#startTime').datebox('getValue')
                    var endTime = $('#endTime').datebox('getValue')
                    var dg = $('#demand');
                    dg.datagrid('enableFilter');
                    dg.datagrid('load', { startTime: startTime ? startTime : '', endTime: endTime ? endTime : '' });
                }

                // 构建需求计划datagrid
                function bingGrid() {
                    var dg = $('#demand');
                    dg.datagrid({
                        title: '',
                        // data: gridData,
                        queryParams: {
                            startTime: $('#startTime').datebox('getValue') ? $('#startTime').datebox('getValue') : '',
                            endTime: $('#endTime').datebox('getValue') ? $('#endTime').datebox('getValue') : ''
                        },
                        fitColumns: true,
                        url: 'purchase/need/selectNeedList',
                        iconCls: 'icon-application',
                        clientPaging: false,
                        remoteFilter: true,
                        filterDelay: 0,
                        width: getWidth(0.98),
                        height: 400,
                        nowrap: true,
                        rownumbers: true,
                        animate: false,
                        collapsible: false,
                        singleSelect: true,
                        pageSize: 10,
                        remoteSort: true,
                        pagination: true,
                        frozenColumns: [[{
                            field: 'nedId',
                            title: '需求计划ID',
                            hidden: true,
                            sortable: true,
                            width: 100,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'nedCode',
                            title: '计划编码',
                            sortable: true,
                            formatter: function (val, rec, index) {
                                return '<a href="javascript:void(0)" onclick="setNeedPlanDetailWindowValue(' + index + ')">' + (val ? val : '') + '</a>'
                            }
                        }, {
                            field: 'nedName',
                            title: '计划名称',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        }]],
                        columns: [[
                            {
                                field: 'nedCategory',
                                title: '计划类别',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'nedType',
                                title: '计划类型',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'nedMmType',
                                title: '物资类型',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'nedProCode',
                                title: '项目编码',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'nedProName',
                                title: '项目名称',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'nedPurType',
                                title: '采购类型',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'nedDeptCode',
                                title: '使用单位编码',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'nedDeptName',
                                title: '使用单位名称',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'nedIsUrgent',
                                title: '是否急用',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'createName',
                                title: '制单人名称',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'createTime',
                                title: '创建时间',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'updateTime',
                                title: '更新时间',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'status',
                                title: '状态',
                                sortable: true,
                                formatter: function (val, rec) {
                                    let status = val ? val : '';
                                    return unescape(status == '0' ? '待提交' : '已提交');
                                }
                            }
                        ]],
                        toolbar: [],
                        onLoadSuccess: function () {

                        },
                        onDblClickRow: function () {
                            //todo 双击显示详情
                            let needPlanIem = $('#demand').datagrid('getSelected');
                            console.log(typeof needPlanIem)
                            setNeedPlanDetailWindowValue(needPlanIem);
                            //  $('#needDetailWindow').window('open');
                        }
                    });
                    dg.datagrid('enableFilter');
                }
            </script>

            </html>